package org.example.test.service;

import org.example.test.MovieTypeEnum;
import org.example.test.Rental;

import java.math.BigDecimal;

/**
 * 普通电影策略实现
 */
public abstract class RentalStartegyImpl implements RentalStrategy<Rental>{
    /**
     * 匹配规则
     * @param movieType
     * @return
     */
    public abstract Boolean match(Integer movieType);

    /**
     * 计算金额规则
     * @param obj
     * @return
     */
    public abstract BigDecimal calculatePrice(Rental obj);

    /**
     * 计算积分规则
     * @param obj
     * @return
     */
    public abstract Integer calculateRenterPoints(Rental obj);

    @Override
    public BigDecimal calculateAmount(Rental obj) {
        if(!match(obj.getMovie().getPriceCode())){
            return null;
        }
        return calculatePrice(obj);
    }
    @Override
    public Integer calculatePoints(Rental obj) {
        if(!match(obj.getMovie().getPriceCode())){
            return null;
        }
        return calculateRenterPoints(obj);
    }


}
